package jjn.daily;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author Jiang Jining
 * @since 2023-07-24 23:22
 */
public class LeetCode771 {
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            set.add(jewels.charAt(i));
        }
        int sum = 0;
        for (int i = 0; i < stones.length(); i++) {
            char c = stones.charAt(i);
            if (set.contains(c)) {
                sum++;
            }
        }
        return sum;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String jewels = scanner.nextLine();
        String stones = scanner.nextLine();
        int numOfJewelsInStones = new LeetCode771().numJewelsInStones(jewels, stones);
        System.out.println(numOfJewelsInStones);
    }
}
